<?php
require_once 'tests/base/BaseTestCase.php';
require_once 'modules/dao/constants.php';
require_once 'modules/dao/daoFactory.php';
require_once 'modules/dao/connection.php';
require_once 'modules/service/serviceFactory.php';

class BaseTestUsage extends BaseTestCase {
    
    private $daoFactory = null;
    private $connection = null;

    public function __construct () {
        $this->daoFactory = daoFactory::getInstance();
        $this->connection = Connection::getInstance();
        $this->serviceFactory = serviceFactory::getInstance();
    }

    protected function getCategorysDao () {
        return $this->daoFactory->getCategorysDao();
    }

    protected function truncateCategorys () {
        $this->truncate(Consts::T_CATEGORYS);
    }

    protected function getLinksDao () {
        return $this->daoFactory->getLinksDao();
    }

    protected function truncateLinks () {
        $this->truncate(Consts::T_LINKS);
    }

    private function truncate ($table) {
        $sql = "TRUNCATE TABLE " . $table;
        $this->connection->getConnection()->exec($sql);
        $this->connection->closeConnection();
    }

    /*************************************************************/
    protected function getCategorysService () {
        return $this->serviceFactory->getCategorysService();
    }

    protected function getLinksService () {
        return $this->serviceFactory->getLinksService();
    }

}
?>